package com.mogist.hqc.module.personal.presenter

import com.mogist.hqc.entitys.BaseResponse
import com.mogist.hqc.entitys.response.LoginVo
import com.mogist.hqc.module.personal.contract.BindMobileContract
import com.mogist.hqc.mvp.HttpDto
import com.mogist.hqc.mvp._PresenterImpl
import com.mogist.hqc.util.Constant
import talex.zsw.basecore.util.JsonTool
import talex.zsw.basecore.view.dialog.sweetalertdialog.SweetAlertDialog

/**
 * 作用：绑定手机
 * 作者：赵小白 email:vvtale@gmail.com  
 * 修改人：
 * 修改时间：
 * 修改备注：
 */
class BindMobilePresenter(view: BindMobileContract.View) : _PresenterImpl<BindMobileContract.View, BaseResponse>(
        view), BindMobileContract.Presenter
{
    override fun requestSuccess(response: BaseResponse, http: HttpDto)
    {
        when (http.url)
        {
            Constant.LOGIN_SEND               ->
            {
                if (response.success)
                {
                    mView.disDialog()
                    mView.sendSuccess()
                }
                else
                {
                    mView.showDialog(SweetAlertDialog.ERROR_TYPE, "获取验证码失败", response.message)
                }
            }
            Constant.Bind_Mobile ->
            {
                if (response.success)
                {
                    mView.disDialog()
                    val vo = JsonTool.getObject(response.content, LoginVo::class.java)
                    mView.bindSuccess(vo)
                }
                else
                {
                    mView.showDialog(SweetAlertDialog.ERROR_TYPE, "绑定手机失败", response.message)
                }
            }
        }
    }
}